package com.spsoft.vatoutinv.controller;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.spsoft.core.annotation.AnonymousAccess;
import com.spsoft.core.annotation.Log;
import com.spsoft.core.controller.BaseController;
import com.spsoft.core.enums.LogActionType;
import com.spsoft.core.enums.LogMenuEnum;
import com.spsoft.core.model.Result;
import com.spsoft.vatoutinv.model.dto.vmsfullyfmmessage.VmsFullYfmMessageDto;
import com.spsoft.vatoutinv.model.vo.vmsfullyfmmessage.VmsFullYfmMessageVo;
import com.spsoft.vatoutinv.service.vmsenterpriseinfo.VmsEnterpriseInfoService;
import com.spsoft.vatoutinv.service.vmsfullyfmmessage.VmsFullYfmMessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 预赋码信息管理表 前端控制器
 * </p>
 *
 * @author chenxudong
 * @since 2023-11-28
 */
@RestController
@Api(tags = {"预赋码信息管理"})
@RequestMapping("/vmsFullYfmMessage")
@RequiredArgsConstructor
@Validated
@Slf4j
public class VmsFullYfmMessageController extends BaseController {

    public static final String LOG_MSG = "(预赋码信息控制层)";

    private final VmsEnterpriseInfoService vmsEnterpriseInfoService;

    private final VmsFullYfmMessageService vmsFullYfmMessageService;

    @ApiOperation("查询预赋码信息")
    @AnonymousAccess(value = "/queryVmsFullYfmMessage", method = RequestMethod.POST, permissionCode = "VMS_PRESHARECODE")
    @Log(value = "查询预赋码信息接口", type = LogActionType.SELECT, menuName = LogMenuEnum.PREPAID_CODE)
    public Result<IPage<VmsFullYfmMessageVo>> queryVmsFullYfmMessage(@RequestBody VmsFullYfmMessageDto vmsFullYfmMessageDto) {
        vmsFullYfmMessageDto.setDeptCode(getDeptCode());
        log.info("{}查询预赋码信息：{}", LOG_MSG, JSONObject.toJSONString(vmsFullYfmMessageDto));
        return vmsFullYfmMessageService.queryVmsFullYfmMessage(vmsFullYfmMessageDto);
    }

    // 接口已弃用
    @ApiOperation("调用乐企批量获取预赋码信息")
    @AnonymousAccess(value = "/getVmsFullYfmMessageByLq/close", method = RequestMethod.POST, permissionCode = "VMS_FULL_YFM_MESSAGE_ADD")
    @Log(value = "调用乐企批量获取预赋码信息接口", type = LogActionType.ADD, menuName = LogMenuEnum.PREPAID_CODE)
    public Result<Object> getVmsFullYfmMessageByLq() {
        VmsFullYfmMessageDto vmsFullYfmMessageDto = new VmsFullYfmMessageDto();
        vmsFullYfmMessageDto.setNsrsbh(vmsEnterpriseInfoService.getNsrsbh());
        log.info("{}调用乐企批量获取预赋码信息入参：{}", LOG_MSG, JSONObject.toJSONString(vmsFullYfmMessageDto));
        return vmsFullYfmMessageService.getVmsFullYfmMessageByLq(vmsFullYfmMessageDto, getUser());
    }

}

